<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../static/js/jquery-3.4.1.js"></script>
</head>
<body>
<!--没有设置文件合并的顺序、文件后缀下拉选择-->
<form id="fileform" method="post" enctype="multipart/form-data">
    <input type="file" name="files[]" id="files" multiple>
    <br><br>
    合成后的文件名：<input type="text" name="mergename" id="mergename">
    <input type="button" value="合成" id="domerge">
</form>
<br>
<br>
<form id="delform" method="post" enctype="multipart/form-data">
    要删除页数的文件<input type="file" name="delfile" id="delfile">
    From <input type="text" name="formp" id="fromp">
    TO <input type="text" name="endp" id="endp">
    <input type="button" value="删页" id="dodel">
</form>

<script src="../js/jquery-3.4.1.js"></script>
<script>
    $(function () {
        $('#domerge').click(function () {
            // var form=$('#fileform');
            // form.attr('action','/pdfserver/edit/domerge');
            // form.submit();

            // var fd=new FormData($('#fileform')[0]);
            var formdata=new FormData();
            var thisf=document.getElementById('files');
            var files=thisf.files;

            for(var i=0;i<files.length;i++){
                formdata.append('mergefile[]',files[i]);
            }

            var mergename=JSON.stringify($('#mergename').serialize());
            formdata.set('mergename',mergename);

            $.ajax({
                type: 'post',
                url: "/pdfserver/edit/domerge",
                data: formdata,
                contentType: false,
                processData: false,

                success: function (data) {
                    alert("success");
                },
                error: function () {
                }
            })
        });

        $('#dodel').click(function () {
            var formdata=new FormData();
            var delfile=$('#delfile')[0].files[0];
            formdata.set('delfile',delfile);

            var fromp=$('#fromp').val();
            var endp=$('#endp').val();
            formdata.set('fromp',fromp);
            formdata.set('endp',endp);

            $.ajax({
                url:'/pdfserver/edit/dodel',
                type:'post',
                data:formdata,
                contentType: false,
                processData: false,
                success: function (result) {
                    // alert(result);
                    if(result>0){
                        alert("change success");
                    }else {
                        alert("页数范围错误");
                    }
                },
                error: function () {

                }
            });
        });
    })

</script>

<!--<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>-->
</body>
</html>